﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ARR.UI.Commands;
using ARR.Shared;
using ARR.UI.Helpers;

namespace ARR.UI.ViewModels
{
    public class AlertViewModel : ViewModelBase
    {

        private ICommand closeCommand;
        private string title;
        private AlertType type;
        

        public ICommand CloseCommand
        {
            get
            {
                if (closeCommand == null)
                {
                    closeCommand = new RelayCommand(param => Close());
                }

                return closeCommand;
            }
        }

        public string ImageSourcePath 
        {
            get
            {
                string path;

                switch (Type)
                {
                    case AlertType.Error: path = "/Images/Error-32.png"; break;
                    case AlertType.Information: path = "/Images/Information-32.png"; break;
                    case AlertType.Warning: path = "/Images/Warning-32.png"; break;
                    default: path = "/Images/Information-32.png"; break;
                }

                return path;
            }
        }

        public string Text { get; set; }

        public string Title
        {
            get { return string.IsNullOrWhiteSpace(title) ? Labels.AlertaTituloPorDefecto : title; }
            set { title = value; }
        }

        public AlertType Type
        {
            get { return type; }
            set { type = value; }
        }

                
        private void Close()
        {
            WindowManager.CloseView(this);
        }
    }

    public enum AlertType
    {
        Information,
        Warning,
        Error
    }
}
